<?php

class Core_Backend_Component_Permission_View_Accredit_Action_Index extends Core_Backend_Share_View_Grid {

    protected function buildToolbar($toolbar) {
    	parent::buildToolbar($toolbar);
    	$group = $toolbar->createGroup();
        $group->addLink($this->getUrl(array('areaid'=>$this->getCurrentAreaId()), 'create'), $this->__('share.button.create'));
    }

    protected function buildGrid($grid) {
        $this->getTemplate()->assignMulti(array('areas'=>$this->getAreas(), 'current_area_id'=>$this->getCurrentAreaId()));
        $grid->setId('accredit_grid')->setPrimaryKey('id');
        $grid->addLabelColumn($this->__('share.label.component'), 'component_name', '{component_name}')
                ->setWidth(100);
        $grid->addLabelColumn($this->__('share.label.controller'), 'controller_name', '{controller_name}')
                ->setWidth(100);
        $grid->addLabelColumn($this->__('share.label.action'), 'action_name', '{action_name}')
                ->setWidth(100);
        $grid->addLabelColumn($this->__('permission.label.accessControl'), 'access_control', '{access_control}')
                ->setWidth(200);
        $grid->addLinkColumn('#', 'edit', $this->getUrl(array('id' => '{id}'), 'edit'), $this->__('share.button.edit'))
                ->setWidth(40)
                ->setAlign('center');
        $grid->setDataSource($this->getList()->toArray());
        parent::buildGrid($grid);
    }

    protected function buildPagination($pagination) {
        $url = $this->getPaginationUrl(array('areaid'=>$this->getCurrentAreaId()));
        $pagination->setUrlFormat($url)
                   ->setRecordCount($this->getRecords());
        parent::buildPagination($pagination);
    }

}